home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / uupc11ys.zip / LIB / LIB.H < prev    next >
C/C++ Source or Header  |  1993-04-04  |  11KB  |  271 lines

  1. /*--------------------------------------------------------------------*/
  2. /*      l i b . h                                                     */
  3. /*--------------------------------------------------------------------*/
  4.  
  5. /*--------------------------------------------------------------------*/
  6. /*    Changes Copyright (c) 1990-1993 by Kendra Electronic            */
  7. /*    Wonderworks.                                                    */
  8. /*                                                                    */
  9. /*    All rights reserved except those explicitly granted by the      */
  10. /*    UUPC/extended license agreement.                                */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /*--------------------------------------------------------------------*/
  14. /*                          RCS Information                           */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. /*
  18.  *    $Id: lib.h 1.5 1993/04/04 21:51:00 ahd Exp $
  19.  *
  20.  *    Revision history:
  21.  *    $Log: lib.h $
  22.  *     Revision 1.5  1993/04/04  21:51:00  ahd
  23.  *     Update copyright
  24.  *
  25.  *     Revision 1.4  1993/03/06  23:09:50  ahd
  26.  *     Break variable names out of master lib.h
  27.  *
  28.  *     Revision 1.3  1992/12/01  04:39:34  ahd
  29.  *     Add SpeedOverMemory
  30.  *
  31.  * Revision 1.2  1992/11/22  21:31:22  ahd
  32.  * Allow strpool() to allocate memory for const strings
  33.  *
  34.  * Revision 1.1  1992/11/16  05:00:26  ahd
  35.  * Initial revision
  36.  *
  37.  */
  38.  
  39. #ifndef __LIB
  40. #define __LIB
  41.  
  42. #include <confvars.h>
  43.  
  44. /*--------------------------------------------------------------------*/
  45. /*     Environment variables set by UUXQT before invoking modules     */
  46. /*--------------------------------------------------------------------*/
  47.  
  48. #define UU_USER "UU_USER"
  49. #define UU_MACHINE "UU_MACHINE"
  50. #define LOGNAME "LOGNAME"
  51. #define RMAIL   "rmail"
  52.  
  53. /*--------------------------------------------------------------------*/
  54. /*                   Global configuration variables                   */
  55. /*--------------------------------------------------------------------*/
  56.  
  57. #define SYSRCSYM "UUPCSYSRC"
  58. #define USRRCSYM  "UUPCUSRRC"
  59. #define SYSDEBUG  "UUPCDEBUG"    /* Initialize debug level ahd       */
  60.  
  61. /*--------------------------------------------------------------------*/
  62. /*                 Macro for recording when UUPC dies                 */
  63. /*--------------------------------------------------------------------*/
  64.  
  65. #define panic()  bugout( __LINE__, cfnptr)
  66.  
  67. /*--------------------------------------------------------------------*/
  68. /*                 Macro for generic error messages from DOS          */
  69. /*--------------------------------------------------------------------*/
  70.  
  71. #define printerr( x )  prterror( __LINE__, cfnptr, x)
  72.  
  73. /*--------------------------------------------------------------------*/
  74. /*                  Convert hours/minutes to seconds                  */
  75. /*--------------------------------------------------------------------*/
  76.  
  77. #define hhmm2sec(HHMM)    ((time_t)(((HHMM / 100) * 60L) + \
  78.                            (time_t)(HHMM % 100)) * 60L)
  79.  
  80. /*--------------------------------------------------------------------*/
  81. /*                     Configuration file defines                     */
  82. /*--------------------------------------------------------------------*/
  83.  
  84. #define B_REQUIRED 0x00000001L /* Line must appear in configuration   */
  85. #define B_FOUND    0x00000002L /* We found the token                  */
  86.  
  87. #define B_GLOBAL   0x00000004L /* Must not appear in PERSONAL.RC      */
  88. #define B_LOCAL    0x00000008L /* The opposite of B_GLOBAL, sort of   */
  89.  
  90. #define B_MTA      0x00000010L /* Used by Mail Delivery (RMAIL)       */
  91. #define B_MUA      0x00000020L /* Used by Mail User Agent (MAIL)      */
  92. #define B_MUSH     0x00000040L /* Used by MUSH - Not used by UUPC     */
  93. #define B_NEWS     0x00000080L /* Used by NEWS software               */
  94. #define B_UUCICO   0x00000100L /* Used by transport program UUCICO    */
  95. #define B_UUCP     0x00000200L /* Used by UUCP command                */
  96. #define B_UUPOLL   0x00000400L /* UUPOLL program                      */
  97. #define B_UUSTAT   0x00000800L /* UUSTAT, UUSUB, UUNAME programs      */
  98. #define B_UUXQT    0x00001000L /* Used by queue processor UUXQT       */
  99. #define B_INSTALL  0x00002000L /* Used by install program only        */
  100. #define B_MAIL     (B_MUA | B_MTA | B_MUSH)
  101. #define B_SPOOL    (B_MTA | B_NEWS | B_UUCICO | B_UUXQT | B_UUCP | B_UUSTAT)
  102. #define B_ALL      (B_MAIL|B_SPOOL|B_NEWS|B_UUPOLL|B_UUSTAT)
  103.  
  104. #define B_INTEGER  0x00010000L /* Pointer is to short int, not string */
  105. #define B_TOKEN    0x00020000L /* Pointer is one word, ignore blanks  */
  106. #define B_BOOLEAN  0x00040000L /* Pointer is to boolean keywords      */
  107. #define B_LIST     0x00080000L /* Pointer to array of char pointers   */
  108. #define B_CLIST    0x00100000L /* Pointer to array of char pointers,
  109.                                   input is separated by colons, not
  110.                                   spaces                              */
  111. #define B_STRING   0x00200000L /* String value (same as original UUPC
  112.                                   configuration processor             */
  113. #define B_NORMAL   0x00400000L /* Normalize backslashes to slashes in
  114.                                   in this variable                    */
  115. #define B_OBSOLETE 0x00800000L /* Option is obsolete, should be
  116.                                   deleted                             */
  117. #define B_MALLOC   0x01000000L  /* Use malloc(), not newstr()         */
  118. #define B_PATH     (B_TOKEN | B_NORMAL)
  119.                                /* DOS Path name                       */
  120.  
  121. /*--------------------------------------------------------------------*/
  122. /*                     General defines and macros                     */
  123. /*--------------------------------------------------------------------*/
  124.  
  125. #define  MESSAGESEP "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\n"
  126.  
  127. #define DCSTATUS    "hostatus"
  128. #define PASSWD      "passwd"
  129. #define PATHS       "hostpath"
  130. #define PERMISSIONS "permissn"
  131. #define SYSLOG      "syslog"
  132. #define SYSTEMS     "systems"
  133. #define ACTIVE      "active"
  134.  
  135. #define WHITESPACE " \t\n\r"
  136.  
  137. /*--------------------------------------------------------------------*/
  138. /*    Equality macros                                                 */
  139. /*--------------------------------------------------------------------*/
  140.  
  141. #define equal(a,b)               (!strcmp(a,b))
  142. #define equali(a,b)              (!stricmp(a,b))                     /*ahd */
  143. #define equalni(a,b,n)           (!strnicmp(a,b,n))                  /*ahd */
  144. #define equaln(a,b,n)            (!strncmp(a,b,n))
  145.  
  146. #ifndef __FILE__
  147. #error __FILE__ must be defined!!!
  148. #endif
  149.  
  150. #define currentfile()            static char *cfnptr = __FILE__
  151. #define checkref(a)              (checkptr(a, cfnptr ,__LINE__))     /*ahd */
  152. #define newstr(a)                (strpool(a, cfnptr ,__LINE__))
  153. #ifndef NOSAFEFREE
  154. #define free(a)                  (safefree(a, cfnptr ,__LINE__))
  155. #endif
  156.  
  157. #define nil(type)               ((type *)NULL)
  158.  
  159. /*--------------------------------------------------------------------*/
  160. /*                     Configuration table layout                     */
  161. /*--------------------------------------------------------------------*/
  162.  
  163. typedef struct ConfigTable {
  164.    char *sym;
  165.    char **loc;
  166.    CONFIGBITS bits;
  167. } CONFIGTABLE;
  168.  
  169. /*--------------------------------------------------------------------*/
  170. /*                    Boolean options table layout                    */
  171. /*--------------------------------------------------------------------*/
  172.  
  173. typedef struct FlagTable {
  174.    char *sym;
  175.    int position;
  176.    CONFIGBITS bits;
  177. } FLAGTABLE;
  178.  
  179. /*--------------------------------------------------------------------*/
  180. /*                            linked list                             */
  181. /*--------------------------------------------------------------------*/
  182.  
  183. struct file_queue {
  184.    char name[FILENAME_MAX];
  185.    struct file_queue *next_link;
  186. } ;
  187.  
  188. /*--------------------------------------------------------------------*/
  189. /*                          Global variables                          */
  190. /*--------------------------------------------------------------------*/
  191.  
  192. extern int debuglevel;
  193. extern FILE *logfile;
  194. extern boolean bflag[F_LAST];
  195.  
  196. extern FLAGTABLE configFlags[];
  197.  
  198. /*--------------------------------------------------------------------*/
  199. /*                        Function prototypes                         */
  200. /*--------------------------------------------------------------------*/
  201.  
  202. void prterror(const size_t lineno, const char *fname, const char *prefix);
  203.  
  204. extern void checkptr(const void *block, const char *file, const int line);
  205.  
  206. extern int MKDIR(const char *path);
  207.                               /* Make a directory              ahd */
  208.  
  209. extern int CHDIR(const char *path);
  210.                               /* Change to a directory          ahd */
  211.  
  212. int RENAME(const char *oldname, const char *newname );
  213.  
  214. extern FILE *FSOPEN(const char *name,
  215.                    const char *mode );
  216.  
  217. #define FOPEN( name, mode, ftype ) FSOPEN( name, mode ftype )
  218.                               /* Since the last two are literals,
  219.                                  we just concat them together for
  220.                                  the call                         */
  221.  
  222. extern void options(char *s,
  223.                     SYSMODE sysmode ,
  224.                     FLAGTABLE *flags,
  225.                     boolean *xflag);
  226.  
  227. int getargs(char *line,
  228.             char **flds);                                   /* ahd */
  229.  
  230. void printmsg(int level, char *fmt, ...);
  231.  
  232. boolean configure( CONFIGBITS program );
  233.  
  234. boolean getconfig(FILE *fp,
  235.                   SYSMODE sysmode,
  236.                   CONFIGBITS program,
  237.                   CONFIGTABLE *table,
  238.                   FLAGTABLE *btable);
  239.  
  240. boolean processconfig(char *buff,
  241.                   SYSMODE sysmode,
  242.                   CONFIGBITS program,
  243.                   CONFIGTABLE *table,
  244.                   FLAGTABLE *btable);
  245.  
  246. void bugout( const size_t lineno, const char *fname);
  247.  
  248. char *strpool( const char *input , const char *file, size_t line);
  249.  
  250. void safefree( void *input , const char *file, size_t line);
  251.  
  252. char *normalize( const char *path );
  253.  
  254. #ifdef __GNUC__
  255. char *strlwr( char *s );
  256. #endif
  257.  
  258. /*--------------------------------------------------------------------*/
  259. /*                   Compiler specific information                    */
  260. /*--------------------------------------------------------------------*/
  261.  
  262. #if defined(__CORE__)
  263. extern   char *copyright;
  264. extern   char *copywrong;
  265. extern   long *lowcore;
  266. #endif   /* defined(__CORE__)   */
  267.  
  268. #define msdos                 /* Required by dain bramaged compiler  */
  269.  
  270. #endif   /* ifndef __LIB */
  271.